﻿<AvalonDock:DocumentContent x:Class="Dispatcher.Views.PlaceSearchView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:Converters="clr-namespace:Dispatcher.Converters"
                            xmlns:AvalonDock="clr-namespace:AvalonDock;assembly=AvalonDock" Title="PlaceSearchView" 
                            Height="500" Width="578">

    <AvalonDock:DocumentContent.Resources>

        <Converters:IdFormatConverter x:Key="IdFormatConverter"/>
        
        <DataTemplate x:Key="ComboBoxItemTemplate">
                <StackPanel Orientation="Horizontal">
                <CheckBox IsChecked="{Binding IsChecked}" Checked="CheckBox_Checked" Unchecked="CheckBox_Checked">
                    <StackPanel Orientation="Horizontal" Width="200">
                        <TextBlock Text="{Binding Path=Id, Converter={StaticResource IdFormatConverter}}"  Width="Auto"/>
                        <TextBlock Text="{Binding Path=Name}" ToolTip="{Binding Path=Description}"  Width="Auto"/>
                    </StackPanel> 
                </CheckBox>
            </StackPanel>
            </DataTemplate>

        <DataTemplate x:Key="LocationListBoxTemplate">
            <StackPanel Orientation="Horizontal">
                <CheckBox IsChecked="{Binding IsChecked}" Checked="CheckBox_Checked" Unchecked="CheckBox_Checked">
                    <StackPanel Orientation="Horizontal" Width="200">
                        <TextBlock Text="{Binding Path=Id, Converter={StaticResource IdFormatConverter}}"  Width="Auto"/>
                        <TextBlock Text="{Binding Path=Name}" ToolTip="{Binding Path=Description}"  Width="Auto"/>
                        <TextBlock> -</TextBlock>
                        <TextBlock Text="{Binding Path=Location.Name}" ToolTip="{Binding Path=Description}"  Width="Auto"/>
                    </StackPanel>
                </CheckBox>
            </StackPanel>
        </DataTemplate>

        <DataTemplate x:Key="ReservedEventTemplate">
            <StackPanel Orientation="Horizontal">
                <CheckBox IsChecked="{Binding IsChecked}" Checked="CheckBox_Checked" Unchecked="CheckBox_Checked">
                    <StackPanel Orientation="Horizontal" Width="Auto">
                        <TextBlock Text="{Binding Path=Id, Converter={StaticResource IdFormatConverter}}"  Width="Auto"/>
                        <TextBlock Text="{Binding Path=Name}" ToolTip="{Binding Path=Description}"  Width="Auto"/>
                        <TextBlock Text=" ("/>
                        <TextBlock Text="{Binding Path=StartTime}" ToolTip="{Binding Path=Description}"  Width="Auto"/>
                        <TextBlock Text=" - "/>
                        <TextBlock Text="{Binding Path=EndTime}" ToolTip="{Binding Path=Description}"  Width="Auto"/>
                        <TextBlock Text=") =>"/>
                        <TextBlock Text="{Binding Path=Place.Id, Converter={StaticResource IdFormatConverter}}"  Width="Auto"/>
                        <TextBlock Text=" room: "/>
                        <TextBlock Text="{Binding Path=Place.Name}" ToolTip="{Binding Path=Description}"  Width="Auto"/>
                        <TextBlock Text=" - "/>
                        <TextBlock Text="{Binding Path=Place.Location.Name}" ToolTip="{Binding Path=Description}"  Width="Auto"/>
                    </StackPanel>
                </CheckBox>
            </StackPanel>
        </DataTemplate>
        
    </AvalonDock:DocumentContent.Resources>
    <ScrollViewer VerticalScrollBarVisibility="Auto">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="157*" />
            <RowDefinition Height="40*" />
        </Grid.RowDefinitions>
        
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition />
        </Grid.ColumnDefinitions>

        <TextBlock Grid.Column="0" Grid.Row="0" Text="From date" VerticalAlignment="Center" Margin="5,0"/>
        <TextBlock Grid.Column="0" Grid.Row="1" Text="To date" VerticalAlignment="Center" Margin="5,0"/>
        <TextBlock Grid.Column="0" Grid.Row="2" Text="From time" VerticalAlignment="Center" Margin="5,0"/>
        <TextBlock Grid.Column="0" Grid.Row="3" Text="To time" VerticalAlignment="Center" Margin="5,0"/>
        <TextBlock Grid.Column="2" Grid.Row="0" Text="Capacity" VerticalAlignment="Center" Margin="5,0"/>
        <TextBlock Grid.Column="2" Grid.Row="1" Text="Locations" VerticalAlignment="Center" Margin="5,0"/>
        <TextBlock Grid.Column="2" Grid.Row="2" Text="Place types" VerticalAlignment="Center" Margin="5,0"/>
        <TextBlock Grid.Column="2" Grid.Row="3" Text="Equipment types" VerticalAlignment="Center" Margin="5,0"/>
        <DatePicker Grid.Column="1" Grid.Row="0" Margin="5" SelectedDate="{Binding FromDate, Mode=TwoWay}"/>
        <DatePicker Grid.Column="1" Grid.Row="1" Margin="5" SelectedDate="{Binding ToDate, Mode=TwoWay}"/>
        <TextBox Grid.Column="1" Grid.Row="2" Margin="5" Text="{Binding FromTime, Mode=TwoWay}"/>
        <TextBox Grid.Column="1" Grid.Row="3" Margin="5" Text="{Binding ToTime, Mode=TwoWay}"/>
        <TextBox Grid.Column="3" Grid.Row="0" Margin="5" Text="{Binding Capacity, Mode=TwoWay}" Width="150"/>
            <ComboBox Grid.Column="3" Grid.Row="1" Margin="5" ItemTemplate="{StaticResource ComboBoxItemTemplate}" Name="Combo1" ItemsSource="{Binding Path=ModelContainer.LocationSet}" IsEditable="True" IsReadOnly="True" Text="Select locations..."/>
            <ComboBox Grid.Column="3" Grid.Row="2" Margin="5" ItemTemplate="{StaticResource ComboBoxItemTemplate}" Name="Combo2" ItemsSource="{Binding Path=ModelContainer.PlaceTypeSet}" IsEditable="True" IsReadOnly="True" Text="Select place types..."/>
            <ComboBox Grid.Column="3" Grid.Row="3" Margin="5" ItemTemplate="{StaticResource ComboBoxItemTemplate}" Name="Combo3" ItemsSource="{Binding Path=ModelContainer.EquipmentTypeSet}" IsEditable="True" IsReadOnly="True" Text="Select equipment types..."/>
        <Button Grid.Column="1" Grid.Row="4" Margin="5" Content="Search >>" Command="Search" Click="Button_Click" />
        
        <TextBlock Grid.Column="0" Grid.Row="6" Margin="5" Text="{Binding Path=FreePlaces.Count}" HorizontalAlignment="Center"/>
            <ListBox Grid.Column="0" Grid.Row="7" Margin="10" ItemsSource="{Binding FreePlaces}" ItemTemplate="{StaticResource LocationListBoxTemplate}" Height="200" Width="250" Grid.ColumnSpan="2"/>
            <ListBox Grid.Column="2" Grid.Row="7" Margin="10" ItemsSource="{Binding ReservedEvents}" ItemTemplate="{StaticResource ReservedEventTemplate}" Height="200" Width="Auto" Grid.ColumnSpan="3"/>
            <Button Grid.Column="1" Grid.Row="6" Margin="5" Content="Reserve >>" Command="Favorites"  />
            <Button Grid.Column="3" Grid.Row="6" Margin="5" Content="Erase" Command="ApplicationCommands.Delete"  />
        </Grid>
    </ScrollViewer>
</AvalonDock:DocumentContent>
